package study.poker;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class DealCards {
    public void deal(List<String> list){
        try {
            System.out.println("下边进入游戏发牌时间");
            String[] player = new String[2];
            Scanner input = new Scanner(System.in);
            for (int i = 0; i < 2; i++) {
                int n = i + 1;
                System.out.println("请输入第" + n + "位玩家的姓名");
                player[i] = input.next();
                System.out.println("已经获取到第" + n + "为玩家的姓名为：" + player[i]);
            }
            System.out.println("录入完毕,共两位玩家，分别是：" + player[0] + "和" + player[1]);
            System.out.println("下边开始发牌");
            List<String> player1 = new ArrayList<String>();
            List<String> player2 = new ArrayList<String>();
            for (int j = 0; j < 4; j++) {
                String card = list.get(j);
                if (j % 2 == 0) {
                    player1.add(card);
                } else {
                    player2.add(card);
                }
            }
            System.out.println("发牌完毕，现在" + player[0] + "手里有" + player1.size() + "张牌；分别是"+player1.get(0)+"和"+player1.get(1)+";" + player[1] + "手里有" + player2.size() + "张牌；分别是"+player2.get(0)+"和"+player2.get(1)+";");

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
